/***********************************************************
 * Product Name: ExcelQuicker
 * Copyright (c)2005, Eunge
 * Author: Eunge
 * Web Site: www.eudev.net
 * Mail/MSN: eudev.net@yeah.net
 * ********************************************************/
using System;
using System.IO;

namespace ExcelQuicker.Framework
{
	/// <summary>
	/// Configration
	/// </summary>
	[Serializable]
	public class EQConfiguration: EQObject 
	{
		private static string mTemporaryFilePath = "";
		private static string mLanguage = "";
		private static string mXmlFileName = "";
		private static string mOutputFilePath = "";
		private static string mTemplateFilePath = "";

		/// <summary>
		/// Set/Get the temp path of ExcelQuicker. It will save some temporary files in this folder
		/// </summary>
		public static string TemporaryFilePath
		{
			get
			{
				return EQConfiguration.mTemporaryFilePath;
			}
			set
			{
				string strPath = value.Trim();
				if((strPath.LastIndexOf(@"\") != strPath.Length - 1) && (strPath.LastIndexOf(@"/") != strPath.Length - 1))
					strPath += @"\";
				EQConfiguration.mTemporaryFilePath = strPath;
			}
		}


		/// <summary>
		/// Set/Get message language signed in the xml file,ect CN, EN and so on.
		/// </summary>
		public static string Language
		{
			get
			{
				return EQConfiguration.mLanguage;
			}
			set
			{
				EQConfiguration.mLanguage = value;
			}
		}


		/// <summary>
		/// Set/Get the physical file name of xml message file
		/// </summary>
		public static string XmlFileName
		{
			get
			{
				return EQConfiguration.mXmlFileName;
			}
			set
			{
				if(File.Exists(value))
					EQConfiguration.mXmlFileName = value;
				else
				{
					throw new EQException("(EQException)The XML message file doesn't exist.");
				}
			}
		}


		/// <summary>
		/// Set/Get the output file path. If you don't specialize the output file name when construct the EQApplication object, ExcelQuicker will output report file under this folder. etc, C:\Inetpub\wwwroot\eqhtmlquicker\
		/// </summary>
		public static string OutputFilePath
		{
			get
			{
				return EQConfiguration.mOutputFilePath;
			}
			set
			{
				if(!Directory.Exists(value))
					throw new EQException("EQ1003", new string[]{value});
				if(value[value.Length - 1] == '\\')
					EQConfiguration.mOutputFilePath = value;
				else
					EQConfiguration.mOutputFilePath = value + "\\";
			}
		}


		/// <summary>
		/// Set/Get the regular template file path.
		/// </summary>
		public static string TemplateFilePath
		{
			get
			{
				return EQConfiguration.mTemplateFilePath;
			}
			set
			{
				if(!Directory.Exists(value))
					throw new EQException("EQ1038", new string[]{value});
				if(value[value.Length - 1] == '\\')
					EQConfiguration.mTemplateFilePath = value;
				else
					EQConfiguration.mTemplateFilePath = value + "\\";
			}
		}
	}
}
